package com.iotteam.androidbase.moudules.sensor_detail.view;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.iotteam.androidbase.R;
import com.iotteam.androidbase.base.ToolbarActivity;
import com.iotteam.androidbase.moudules.sensor_detail.presenter.ISensorInfoPresenter;
import com.iotteam.androidbase.moudules.sensor_detail.presenter.SensorInfoPresenter;

/**
 * Created by lidechen on 6/4/17.
 */

public class SensorInfoActivity extends ToolbarActivity implements ISensorInfoView {

    private ISensorInfoPresenter mPresenter;
    private TextView mInfoText;

    /**
     * id : 3
     * terminalid : 865067020720535
     * sim : 2345667788
     * password : d326f5
     * verifycode : 14864245
     * hardware : YJ-GPRSBOARD-V1.0
     * firmware : YJ-GPRSBOARD-V1.0-00
     * create_time : 2017-05-28 22:30:05
     * posx : 115.789
     * posy : 90.657
     * angles : 90
     * power : 90
     * ts : 2017-05-30 15:37:07
     * alertfall : 0
     * alertdefense : 1
     * locatesrc : 0
     * feedback : 2
     * message1 : 。。
     * message2 : 啊
     * message3 : 456
     * bindings : 15910992968
     * status : 1
     */

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_sensor_info;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mPresenter = new SensorInfoPresenter(SensorInfoActivity.this);

        mInfoText = (TextView) findViewById(R.id.tv_info);
    }

    @Override
    protected void onResume() {
        super.onResume();

        mPresenter.getSensorInfo();
    }

    public static void launch(Context context) {
        context.startActivity(new Intent(context, SensorInfoActivity.class));
    }

    @Override
    public void displaySensorInfo(String str) {
        mInfoText.setText(str);
    }

    @Override
    public void showLoading() {
        mWaitDialog.show();
    }

    @Override
    public void dismissLoading() {
        mWaitDialog.dismiss();
    }
}
